package com.xunfang.mapper;

import com.xunfang.bean.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author yellow Docter
 * @date 2023 -10-17
 * @desc
 */

public interface UserMapper {

    @Select("select * from t_user where id = #{id}")
    User findUserById(Integer id);

    @Insert("insert into t_user(id,name,age,info) values (#{id},#{name},#{age},#{info})")
    void addUser(User user);

    @Delete("delete from t_user where id = #{id}")
    int deleteUserById(Integer id);

    //mybatis的多个参数 需要 使用注解标记
    @Select("select * from t_user limit #{start},#{pageSize}")
    List<User> pageUsers(@Param("start") Integer start, @Param("pageSize") Integer pageSize);

    //查询所有
    @Select("select * from t_user")
    List<User> findUsers();

}
